﻿using DesignModeConsole.ClassRelation;
using DesignModeConsole.OOPAndPOP.AuthSample;
using DesignModeConsole.创建型.单例模式;
using DesignModeConsole.创建型.原型模式;
using DesignModeConsole.创建型.工厂方法模式;
using DesignModeConsole.创建型.建造者模式;
using DesignModeConsole.创建型.抽象工厂模式;
using DesignModeConsole.创建型.简单工厂模式;
using DesignModeConsole.结构型.享元模式;
using DesignModeConsole.结构型.代理模式;
using DesignModeConsole.结构型.外观模式;
using DesignModeConsole.结构型.桥接模式;
using DesignModeConsole.结构型.组合模式;
using DesignModeConsole.结构型.装饰器模式;
using DesignModeConsole.结构型.适配器模式;
using DesignModeConsole.行为型.中介者模式;
using DesignModeConsole.行为型.命令模式;
using DesignModeConsole.行为型.备忘录模式;
using DesignModeConsole.行为型.模板模式;
using DesignModeConsole.行为型.状态模式;
using DesignModeConsole.行为型.策略模式;
using DesignModeConsole.行为型.职责链模式;
using DesignModeConsole.行为型.观察者模式;
using DesignModeConsole.行为型.解释器模式;
using DesignModeConsole.行为型.访问者模式;
using DesignModeConsole.行为型.迭代器模式;

namespace DesignModeConsole;

internal static class Program
{
    private static void Main()
    {
        Console.WriteLine("项目执行结束 !");

        const DesignModeEnum mode = DesignModeEnum.SingletonMode;
        Console.WriteLine($"当前执行的模式是：{mode.ToString()}");
        var service = RunFactory(mode);
        service.Main();

        Console.WriteLine("项目执行结束 !");
        //Console.ReadLine();
    }

    /// <summary>
    /// 获取运行服务的工厂
    /// </summary>
    /// <param name="designMode"></param>
    /// <returns></returns>
    /// <exception cref="ArgumentOutOfRangeException"></exception>
    private static IService RunFactory(DesignModeEnum designMode)
    {
        return designMode switch
        {
            DesignModeEnum.SingletonMode => new SingletonService(),
            DesignModeEnum.SampleFactoryMode => new SampleFactoryService(),
            DesignModeEnum.FactoryMethodMode => new FactoryMethodService(),
            DesignModeEnum.AbstractFactoryMode => new AbstractFactoryService(),
            DesignModeEnum.BuilderMode => new BuilderService(),
            DesignModeEnum.PrototypeMode => new PrototypeService(),
            DesignModeEnum.ProxyMode => new ProxyService(),
            DesignModeEnum.BridgeMode => new BridgeService(),
            DesignModeEnum.DecoratorMode => new DecoratorService(),
            DesignModeEnum.AdapterMode => new AdapterService(),
            DesignModeEnum.FacadeMode => new FacadeService(),
            DesignModeEnum.ComposeMode => new ComposeService(),
            DesignModeEnum.FlyweightMode => new FlyweightService(),
            DesignModeEnum.AuthSample => new AuthService(),
            DesignModeEnum.ClassRelation => new ClassRelationService(),
            DesignModeEnum.ObserverMode => new ObserverService(),
            DesignModeEnum.TemplateMethodMode => new TemplateMethodService(),
            DesignModeEnum.StrategyMode => new StrategyDesignService(),
            DesignModeEnum.ChainResponsibilityMode => new ChainResponsibilityService(),
            DesignModeEnum.StateMode => new StateService(),
            DesignModeEnum.IteratorMode => new IteratorService(),
            DesignModeEnum.VisitorMode => new VisitorService(),
            DesignModeEnum.CommandMode => new CommandService(),
            DesignModeEnum.MementoMode => new MementoService(),
            DesignModeEnum.InterpreterMode => new InterpreterService(),
            DesignModeEnum.MediatorMode => new MediatorService(),
            _ => throw new ArgumentOutOfRangeException(nameof(designMode), designMode, null)
        };
    }
}